<?php

class AddressController extends CommonController{
	
	private $_model;
	
	public function __init(){
		
		$this->_model=K('Address');
	}
	
	
	public function index(){
		
		$data=$this->_model->get_all_data(array('uid'=>$_SESSION['uid']),'defau DESC');
		
//		p($data);
		$this->assign('data',$data);
		
		$this->dis('address');
	}
	
	
	
	
	public function add(){
		
		if(!IS_POST) $this->error('非法请求');
		if(!$this->_model->add_data()) $this->error($this->_model->error);
		$this->success('添加成功');
//		P(Q('post.'));
	}
	
	public function set_defau(){
		
		$this->_model->set_default();
		$this->success('设置成功');
	}
	
	public function del(){
		
		$this->_model->del_data(array('addressid'=>Q('get.addressid')));
		
		$this->success('删除成功');
	}
	
}















